<template>
  <div class="enterpriseHome">
    <div class="cardBox">
      <div class="cardItem" @click="jump('1')">
		<div class="c_left">
			<div class="cardItemTitle1">待处理可疑寄件</div>
        <div class="cardContent1"><span>{{send_dubious_count}}</span>单</div>
		</div>
		<div class="c_right">
			<img src="../../assets/home/t1.png" alt="">	
		</div>
        
      </div>
      <div class="splitArea"></div>
      <div class="cardItem" @click="jump('2')">
		<div class="c_left">
			<div class="cardItemTitle1 ">待处理可疑收件</div>
        <div class="cardContent1"><span>{{receive_dubious_count}}</span>单</div>
		</div>
		<div class="c_right">
			<img src="../../assets/home/t2.png" alt="">	
		</div>
        
      </div>
      <div class="splitArea"></div>
      <div class="cardItem" @click="jump('3')">
		<div class="c_left">
			<div class="cardItemTitle1 ">今日新增寄件</div>
        <div class="cardContent1"><span>{{send_today_count}}</span>单</div>
		</div>
		<div class="c_right">
			<img src="../../assets/home/t3.png" alt="">	
		</div>
        
      </div>
      <div class="splitArea"></div>
      <div class="cardItem" @click="jump('4')">
		<div class="c_left">
			
			<div class="cardItemTitle1 ">今日新增收件</div>
        <div class="cardContent1"><span>{{receive_today_count}}</span>单</div>
		</div>
		<div class="c_right">
			<img src="../../assets/home/t4.png" alt="">	
		</div>
      </div>
      <div class="splitArea"></div>
      <div class="cardItem" @click="jump('5')">
		<div class="c_left">
			
			<div class="cardItemTitle1">累计监管寄件</div>
        <div class="cardContent1"><span>{{send_count}}</span>单</div>
		</div>
		<div class="c_right">
			<img src="../../assets/home/t5.png" alt="">	
		</div>
      </div>
      <div class="splitArea"></div>
      <div class="cardItem" @click="jump('6')">
		<div class="c_left">
			
			<div class="cardItemTitle1">累计监管收件</div>
        <div class="cardContent1"><span>{{receive_count}}</span>单</div>
		</div>
		<div class="c_right">
			<img src="../../assets/home/t6.png" alt="">	
		</div>
      </div>
    </div>
    <div class="enterprisePanel">
      <zyInfoPanel :showUnfoldButton="false" class="heartBox" borderPx="15">
        <div class="pgTitle" slot="title">
          <div class="pgT">
            <img src="../../assets/home/tbtbg2.png" alt="" class="tbtbg">
            <span>智能综合研判热力图</span>
          </div>
        </div>
        <div class="heartMap">
          <heartMap :points="points1" :show="showHeart"></heartMap>
        </div>
      </zyInfoPanel>
      <zyInfoPanel :showUnfoldButton="false" class="tableItem" borderPx="15">
        <img src="../../assets/home/tbbg1.png" alt="" class="tbbg1">
        <div class="pgTitle" slot="title">
          <div class="pgT">
            <img src="../../assets/home/tbtbg1.png" alt="" class="tbtbg">
            <span>综合研判运单列表</span>
          </div>
          <div class="moreBtn" @click="moreData('1')">更多></div>
        </div>
        <div class="ybListBox">
          <div class="ybLi" v-for="item in logistics_list" @click="toDetail(item)">
            <div class="ybLeft">
              <div class="ybTitle">
                <div class="ybTag">{{item.logistics_type_str}}</div>
                <div class="ybNum">{{item.logistics_no}}</div>
              </div>
              <div class="ybPf">研判评分: <span>{{item.score}}</span></div>
              <div class="ybPf">预警方式:{{item.police_names}}</div>
            </div>
            <div class="ybR"><i class="el-icon-arrow-right"></i></div>
          </div>
        </div>
      </zyInfoPanel>
      <zyInfoPanel :showUnfoldButton="false" class="heartBox" borderPx="15">
        <div slot="title">
          <div class="hTabs">
            <div class="hTab" :class="{active: openItem == 1}" @click="openItem = 1">物流企业站点图</div>
            <div class="hTab" :class="{active: openItem == 2}" @click="openItem = 2">合作站点驻点图</div>
          </div>
        </div>
        <div class="heartMap">
          <pointMap :points="points" :show="showPoint"></pointMap>
        </div>
      </zyInfoPanel>
      <zyInfoPanel :showUnfoldButton="false" class="tableItem" borderPx="15">
        <img src="../../assets/home/tbbg2.png" alt="" class="tbbg1">
        <div class="pgTitle" slot="title">
          <div class="pgT">
            <img src="../../assets/home/tbtbg3.png" alt="" class="tbtbg">
            <span>{{title}}</span>
          </div>
          <div class="moreBtn" @click="moreData('2')">更多></div>
        </div>
        <div class="pxList">
          <div class="pxLi" v-for="(item, index) in tableData">
            <div class="cIndex">
              <img src="../../assets/home/i1.png" alt="" v-if="index == 0">
              <img src="../../assets/home/i2.png" alt="" v-else-if="index == 1">
              <img src="../../assets/home/i3.png" alt="" v-else-if="index == 2">
              <span v-else>{{index + 1}}</span>
            </div>
            <div class="cName">{{item.company_name}}</div>
            <div class="split"></div>
            <div class="cTotal">
              <div class="cTotalIt">
                <div class="cNum">{{item.yestday_send_count || 0}}</div>
                <div class="cNumTitle">昨日新增收/寄件</div>
              </div>
              <div class="cTotalIt">
                <div class="cNum">{{item.send_count || 0}}</div>
                <div class="cNumTitle">累计收/寄件</div>
              </div>
            </div>
          </div>
        </div>

      </zyInfoPanel>
    </div>
  </div>
</template>

<script>
	import heartMap from './heartMap'
	import pointMap from './pointMap'

	export default {
		name: "enterpriseHome",
		props: {},
		data() {
			return {
				title: '企业收寄件列表',
				receive_count: 0,
				receive_dubious_count: 0,
				receive_today_count: 0,
				send_count: 0,
				send_dubious_count: 0,
				send_today_count: 0,
				logistics_list: [],
				tableData: [],
				openItem: '1',
				points: [],
				points1: [],
				showHeart: false,
				showPoint: false
			};
		},
		computed: {},
		watch: {
			openItem(newVal) {
				this.title = newVal == '1' ? '企业收寄件列表' : '合作站点收寄件列表'
				this.getDetail();
			}
		},
		components: {heartMap, pointMap},
		methods: {
			jump(type) {
				switch (type) {
					case '1':
						this.$toRoutePath({
							path: '/dubious_logistics_1'
						})
						break;
					case '2':
						this.$toRoutePath({
							path: '/dubious_receive_1'
						})
						break;
					case '3':
						this.$toRoutePath({
							path: '/logistics_list'
						})
						break;
					case '4':
						this.$toRoutePath({
							path: '/receive_list'
						})
						break;
					case '5':
						this.$toRoutePath({
							path: '/logistics_list'
						})
						break;
					case '6':
						this.$toRoutePath({
							path: '/receive_list'
						})
						break;
				}
			},
			toDetail() {
			},
			handleClick() {
			},
			moreData(type) {
				// switch (type) {
				// 	case '1':
				// 		break;
				// 	case '2':
				// 		break;
				// }
				this.$toRoutePath({
					path: '/logistics_list',
					edit: true,
					query: {}
				})
			},
			getData() {
				this.$axios.post(this.$api.g_welcomeNew, {}).then(res => {
					let {code, msg, data} = res;
					if (code == 200) {
						this.receive_count = data.receive_count;
						this.receive_dubious_count = data.receive_dubious_count;
						this.receive_today_count = data.receive_today_count;
						this.send_count = data.send_count;
						this.send_dubious_count = data.send_dubious_count;
						this.send_today_count = data.send_today_count;
						this.logistics_list = data.logistics_list.filter(item => {
							return item;
						}) || []
					} else {
						this.$message.error(msg);
					}
				}).catch(ret => {
					this.$message.error(ret.msg || '服务繁忙，请稍后再试');
				});
			},
			getDetail() {
				this.$axios.post(this.$api.g_getHomeBaseStation, {company_type: this.openItem}).then(res => {
					let {code, msg, data} = res;
					if (code == 200) {
						let points = [], points1 = [];
						this.tableData = data.list || [];
						data.list.forEach(item => {
							let obj = {}, obj1 = {};
							if (item.lat && item.lng) {
								obj.lng = item.lng ? parseFloat(item.lng) : '';
								obj.lat = item.lat ? parseFloat(item.lat) : '';
                obj.company_name = item.company_name || '';
                obj.sj_count = item.count;
                points.push(obj)
							}
							if (item.lat && item.lng && item.count > 0) {
								obj1.lng = item.lng ? parseFloat(item.lng) : '';
								obj1.lat = item.lat ? parseFloat(item.lat) : '';
								obj1.company_name = item.company_name || '';
								obj1.count = parseFloat(item.count) * 10;
                obj1.sj_count = item.count;
                points1.push(obj1)
							}
						}) || [];
						console.log(points, points1)
						this.points = points || [];
						this.points1 = points1 || [];
						console.log(this.points1)
						this.showHeart = true;
						this.showPoint = true;
					} else {
						this.$message.error(msg);
					}
				}).catch(ret => {
					console.log(ret)
					this.$message.error(ret.msg || '服务繁忙，请稍后再试');
				});

			}
		},
		mounted() {
			this.getData();
			this.getDetail()
		},
		created() {
		}
	}
</script>

<style scoped lang="less" src="@/style/home/index.less">

</style>
<style lang="less">
  .heartMap{
    padding: 0 12px 12px;
  }
  .pgTitle{
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px 12px;

    .pgT{
      display: flex;
      align-items: center;
      span{
        font-family: MiSans, MiSans;
        font-weight: 500;
        font-size: 18px;
        color: #252525;
        line-height: 28px;
      }
    }
    .tbtbg{
      width: 36px;
      height: 36px;
      margin-right: 8px;
    }
  }
  .tableItem{
    position: relative;
  }
  .tbbg1{
    position: absolute;
    top: 0;
    right: 0;
    z-index: 0;
    width: 262px;
    height: 140px;
  }
  .moreBtn{
    font-family: MiSans, MiSans;
    font-weight: 400;
    font-size: 14px;
    color: #5A5A5A;
    line-height: 28px;
    position: relative;
    z-index: 1;
    cursor: pointer;
  }
  .ybListBox{
    display: flex;
    flex-wrap: wrap;
    padding-left: 12px;
    position: relative;
    z-index: 1;
    cursor: pointer;
    .ybLi{
      width: calc(50% - 12px);
      margin-right: 12px;
      display: flex;
      align-items: baseline;
      padding: 12px 16px;
      background: #F6FAFF;
      border-radius: 5px 5px 5px 5px;
      margin-bottom: 12px;

      .ybLeft{
        flex: 1;
        .ybTitle{
          display: flex;
          align-items: center;
          .ybTag{
            padding: 0 9px;
            height: 24px;
            line-height: 24px;
            font-weight: 500;
            font-size: 13px;
            color: #165DFF;
            border-radius: 13px 13px 13px 13px;
            background: #E2EBF9;
            margin-right: 8px;
          }
          .ybNum{
            flex: 1;
            font-family: MiSans, MiSans;
            font-weight: 600;
            font-size: 18px;
            color: #252525;
            line-height: 28px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
        .ybPf{
          font-family: MiSans, MiSans;
          font-weight: 500;
          font-size: 14px;
          color: #5A5A5A;
          margin-top: 4px;
          line-height: 28px;
          span{
            color: #FF7D00;
          }
        }
        .ybPf{
          font-family: MiSans, MiSans;
          margin-top: 4px;
          font-weight: 500;
          font-size: 14px;
          color: #5A5A5A;
          line-height: 28px;
        }
      }
    }
  }
  .pxList{
    position: relative;
    z-index: 2;
    height: 400px;
    overflow-x: hidden;
    overflow-y: auto;
    &::-webkit-scrollbar{
      display: none;
    }
    padding: 0 16px 12px;
    .pxLi{
      display: flex;
      align-items: center;
      padding: 12px;
      background: #FAFCFF;
      margin-bottom: 12px;
      &:last-child{
        margin-bottom: 0;
      }
      .cIndex{
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 31px;
        overflow: hidden;
        img{
          width: 48px;
          height: 31px;
        }
        span{
          font-family: MiSans, MiSans;
          font-weight: 600;
          font-size: 20px;
          color: #B67600;
        }
      }
      .cName{
        flex: 1;
        margin-left: 12px;
        font-family: MiSans, MiSans;
        font-weight: 500;
        font-size: 16px;
        color: #252525;
        line-height: 28px;
      }
      .split{
        height: 32px;
        width: 1px;
        margin-left: 20px;
        margin-right: 32px;
        background: #E6E6E6;
      }
      .cTotal{
        display: flex;
      }
      .cTotalIt{
        margin-right: 32px;
        .cNum{
          font-family: DIN, DIN;
          font-weight: bold;
          font-size: 18px;
          color: #165DFF;
          line-height: 28px;
        }
        .cNumTitle{
          font-family: MiSans, MiSans;
          font-weight: 500;
          font-size: 14px;
          color: #5A5A5A;
          line-height: 28px;
        }
      }
    }
  }

  .hTabs{
    display: flex;
    padding: 16px 12px 12px;
    .hTab{
      font-family: Poppins, Poppins;
      font-weight: 400;
      font-size: 12px;
      padding: 0 20px;
      color: #4E5969;
      height: 36px;
      line-height: 36px;
      border-radius: 6px 6px 6px 6px;
      background: #F8F8F9;
      margin-right: 12px;
      &:last-child{
        margin-right: 0;
      }
      &.active{
        background: #F2F8FF;
        color: #0060FF;
        font-weight: 500;
      }
    }
  }

  @media (min-width: 1280px) and (max-width: 1680px) {
    .home .cardBox .cardItem .c_right{
      width: 60px !important;
      height: 60px !important;
      img{
        width: 60px !important;
        height: 60px !important;
      }
    }
    .home .cardBox .cardItem .c_left .cardItemTitle1{
      font-size: 14px !important;

    }
    .home .cardBox .cardItem .c_left .cardContent1{
      margin-top: 4px !important;
      font-size: 14px !important;
      span{
        font-size: 16px !important;
      }
    }
  }
</style>
